class_name HoldSelfBombScroll
extends BaseHoldItem


func use():
	var player = holder as Player
	
	var self_direct_damage = player.player_data.hp - 1
	var hit_data = HitData.new()
	hit_data.is_critical = true
	hit_data.is_direct_damage = true
	hit_data.direct_damage = self_direct_damage
	hit_data.knockback = 200
	player.take_hit(hit_data)
	
	var inst = (ResourceManager.get_resource("particle_self_bomb_explosion_effect") as PackedScene).instantiate() as ParticleExplosionEffect
	player.level.bullets_parent.add_child(inst)
	inst.global_position = player.ray_cast_point.global_position
	inst.sender = player
	inst.attack = item_data.item_config.attack
	inst.critical_rate = item_data.item_config.critical_rate
	inst.critical_bonus = item_data.item_config.critical_bonus
	inst.knockback = item_data.item_config.knockback
	inst.hit_cam_shake_strength = item_data.item_config.attack_cam_shake_intensity
	inst.hit_cam_shake_duration = item_data.item_config.attack_cam_shake_duration
	
	player.level.camera.start_shake(item_data.item_config.attack_cam_shake_intensity, item_data.item_config.attack_cam_shake_duration)
	
	GlobalData.reduce_item(item_data)
	if item_data.item_count <= 0:
		player.clear_current_hold_item()
